﻿using Coldairarrow.Business.PB;
using Coldairarrow.Entity.DTO;
using Coldairarrow.Entity.PB;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.PB
{
    [Route("/PB/[controller]/[action]")]
    public class PB_PickUpPlanController : BaseApiController
    {
        #region DI

        public PB_PickUpPlanController(IPB_PickUpPlanBusiness pB_PickUpPlanBus)
        {
            _pB_PickUpPlanBus = pB_PickUpPlanBus;
        }

        IPB_PickUpPlanBusiness _pB_PickUpPlanBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<PB_PickUpPlan>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _pB_PickUpPlanBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<PB_PickUpPlan> GetTheData(IdInputDTO input)
        {
            return await _pB_PickUpPlanBus.GetTheDataAsync(input.id);
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(PB_PickUpPlan data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                data.Status = 0;
                data.Deleted = false;
                InitEntity(data);

                await _pB_PickUpPlanBus.AddDataAsync(data);
            }
            else
            {
                await _pB_PickUpPlanBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _pB_PickUpPlanBus.DeleteDataAsync(ids);
        }

        /// <summary>
        /// 通过传入看板id查询数据
        /// </summary>
        /// <param name="DeviceId"></param>
        /// <returns></returns>
        [HttpGet]
        [NoCheckJWT]
        public async Task<List<PB_PickUpPlanList>> GetPickUpPlanList(string DeviceId) {
            return await _pB_PickUpPlanBus.GetPickUpPlanList(DeviceId);
        }


        [HttpPost]
        public async Task<PageResult<PB_PickUpPlanDTO>> GetPickUpPlanLists(PageInput<PB_DispatchConditionDTO> input) {

            var listData= await _pB_PickUpPlanBus.GetPickUpPlanLists(input);
            return listData;
        }
        #endregion
    }
}